﻿using System;
using System.IO;

namespace KMLHelper
{
    /// <summary>
    /// 对象坐标；
    /// 对应标签Point/LineString/Polygon；
    /// 与Placemark是一对一的关系；
    /// </summary>
    public abstract class KMLGeometry
    {
        /// <summary>
        /// 地物类型
        /// </summary>
        protected EnumKMLGeoType geoType = EnumKMLGeoType.NULL;

        protected EnumKMLAltitudeMode altitudeMode = EnumKMLAltitudeMode.NULL;
        /// <summary>
        /// 高程模式
        /// </summary>
        public EnumKMLAltitudeMode AltitudeMode
        {
            set { this.altitudeMode = value; }
        }

        protected double extrude = 1f;
        /// <summary>
        /// 以米为单位的 extrusion 高度值；
        /// 允许对 2 维的图形如地名标注、路径、多边形进行立体化处理；
        /// </summary>
        public double Extrude
        {
            set { this.extrude = value; }
        }
        
        public abstract void Write(StreamWriter sw);

        protected string GetAltitudeMode()
        {
            switch (this.altitudeMode)
            { 
                case EnumKMLAltitudeMode.ClampedToGround:
                    return "clampedToGround";
                case EnumKMLAltitudeMode.RelativeToGround:
                    return "relativeToGround";
                case EnumKMLAltitudeMode.Absolute:
                    return "absolute";
                default:
                    throw new ArgumentException("altitudeMode can't be null!");
            }
        }
    }
}
